<template>
  <div>
    <!-- 头条新闻 -->
    <div class="content">
      <div class="box">
        <div class="card" v-for="item in news" :key="item.id">
          <router-link :to="`/detail/${item.id}`">
            <img :src="`/other/pic/${item.imga.split(',')[0]}`" alt="" />
            <div class="pdown">
              <div class="title">{{ item.title }}</div>
              <!-- <div class="rate">{{item.rate}}<van-icon name="star-o" color="#f5b400"/></div> -->
            </div>
          </router-link>
        </div>
      </div>
    </div>
  </div>
</template>



<script>
export default {
  activated() {
    this.getData();
  },
  mounted() {
    this.getData();
  },
  data() {
    return {
      news: [],
    };
  },
  methods: {
    getData() {
      let url = "/recommend/travel_around?type_id=1";
      this.axios.get(url).then((res) => {
        this.news = res.data.results;
      });
    },
  },
};
</script>

<style lang='scss' scoped>
/*顶部导航栏样式 */
::v-deep .van-nav-bar__text {
  color: white;
}
::v-deep .van-icon {
  color: white;
}
.van-nav-bar__left span {
  color: white;
}
.van-nav-bar {
  background-color: #f5b400;
}
.van-nav-bar .van-icon {
  color: white;
}
::v-deep .van-nav-bar__title {
  color: white;
}

.van-nav-bar__text {
  color: white;
}
.content {
  width: 100vw;
  margin: 270px auto 40px;
  border-radius: 20px;
  padding: 10px 0;
  background-color: #fff;
  display: flex;
  justify-content: center;
  .box {
    width: 100vw;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    margin: 10px 0;
  }

  .card {
    width: 95%;
    margin: 10px;
    overflow: hidden;
    background-color: white;
    break-inside: avoid;
    border-radius: 10px;
    // box-shadow: 1vw 1vw 1vw 0 #eee;
    img {
      display: block;
      width: 100%;
      margin: 0 auto;
      border-radius: 10px;
      position: relative;
    }
    .pdown {
      display: flex;
      flex-direction: column;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      .title {
        width: 90%;
        text-align: center;
        font-size: 16px;
        font-weight: bold;
        color: #333;
        padding: 10px 10px 0 10px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        word-break: break-all;
      }
      .rate {
        font-size: 16px;
        color: #666;
        padding: 10px;
      }
    }
  }
}
</style>
